#include "deleteDuplicates.h"

ListNode* deleteDuplicates(ListNode* head)
{
	if (head->next == nullptr || head == nullptr)
	{
		return head;
	}
	ListNode* pLeft = head;
	ListNode* pRight = head->next;

	while (pRight != nullptr)
	{
		if (pLeft->val != pRight->val)
		{
			pLeft->next = pRight;
			pLeft = pRight;
			pRight = pRight->next;
			continue;
		}

		pLeft->next = nullptr;
		pRight = pRight->next;
	}

	return head;
}
